<template>
  <rx-layout>
    <div slot="center" style>
      <rx-fit>
        <div slot="toolheader" foldheader="true" foldbtn="true" border="false">
          <div class="table-page-search-wrapper" v-if="showSearch==true">
            <a-form layout="inline">
              <a-row :gutter="24">
                    <a-col :span="8">
                      <a-form-item :label="i18n('form.instanceID','流程实例ID')">
                          <a-input :placeholder="i18n('form.instanceID','流程实例ID','input')" v-model="queryParam.Q_INST_ID__S_LK"/>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item :label="i18n('form.owner','所有人ID')">
                          <a-input :placeholder="i18n('form.owner','所有人ID','input')" v-model="queryParam.Q_OWNER_ID__S_LK"/>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item :label="i18n('form.title','任务标题')">
                          <a-input :placeholder="i18n('form.title','任务标题','input')" v-model="queryParam.Q_SUBJECT__S_LK"/>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item :label="i18n('form.task','任务ID')">
                          <a-input :placeholder="i18n('form.task','任务ID','input')" v-model="queryParam.Q_TASK_ID__S_LK"/>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item :label="i18n('transferPage.transferor','转办人')+ID">
                          <a-input :placeholder="i18n('transferPage.transferor','转办人','input')+ID" v-model="queryParam.Q_TO_USER_ID__S_LK"/>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item :label="i18n('form.type','类型(trans,agent)')">
                          <a-input :placeholder="i18n('form.type','类型(trans,agent)','input')" v-model="queryParam.Q_TYPE__S_LK"/>
                      </a-form-item>
                    </a-col>
                <template v-if="advanced">

                </template>
                <a-col :md="8" :sm="24">
              <span class="table-page-search-submitButtons">
                <a-button @click="$refs.table.loadData()" icon="search" type="primary">
                    {{$ti18('rxList.searchBtn', '查询')}}
                </a-button>
                <a-button @click="resetSearch" style="margin-left: 4px">
                    {{$ti18('rxList.resetBtn','重置')}}
                </a-button>
                <a @click="toggleAdvanced" style="margin-left: 8px">
                   {{ advanced ? i18n('list.putAwayBtn','收起') : i18n('list.expansionBtn','展开') }}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
                </a>
              </span>
                </a-col>
              </a-row>
            </a-form>
          </div>
          <div class="table-operator">
            <rx-button alias="bpmTaskTransferAdd" :butn-icon="'plus'" :butn-type="'primary'" :show-no-right="true" @click="add">
                {{$ti18('rxList.newBtn','新建')}}
            </rx-button>
            <rx-button v-if="editEnable && selectedRowKeys.length > 0" alias="bpmTaskTransferEdit" :butn-icon="'edit'"
                       :butn-type="'primary'" :show-no-right="false" @click="editOne">
                {{$ti18('rxList.editBtn','编辑')}}
            </rx-button>




            <a-dropdown v-if="removeEnable && selectedRowKeys.length > 0">
              <rx-button alias="bpmTaskTransferDelete" :butn-icon="'delete'" :butn-type="'danger'"
                         :show-no-right="false" @click="delByIds(selectedRowKeys)">
                  {{$ti18('rxList.delBtn','删除')}}
              </rx-button>
            </a-dropdown>

            <span style="float:right">
             <a-button type="primary" shape="circle" icon="sync" :size="small" @click="refreshGrid"></a-button>
             <a-button type="primary" shape="circle" icon="search" :size="small" @click="toggleSearch"></a-button>
            </span>
          </div>
        </div>
        <rx-grid
                ref="table"
                :allowRowSelect="true"
                :multiSelect="true"
                :columns="columns"
                :defaultPageSize="10"
                url="/api-form/bpm/core/bpmTaskTransfer/query"
                :queryParam="queryParam"
                data-field="result.data"
                :pageSizeOptions="['10','30','40']"
                rowKey="id"
                @selectChange="onSelectChange"
        >
          <span slot="action" slot-scope="{ text, record }" class="actionIcons">
            <span v-if="editEnable && showBtn(false)" @click="edit(record)">
                {{$ti18('rxList.editBtn', '编辑')}}
            </span>
            <span v-if="removeEnable && showBtn(false)" @click="delByIds([record.id])">
                {{$ti18('rxList.delBtn','删除')}}
            </span>
          </span>
        </rx-grid>
      </rx-fit>
    </div>
  </rx-layout>
</template>

<script>
  import BpmTaskTransferApi from '@/api/bpm/core/bpmTaskTransfer'
  import BpmTaskTransferEdit from './BpmTaskTransferEdit'
  import {BaseList} from '@lowcode/jpaas-common-lib';
  export default {
    name: 'BpmTaskTransferList',
    mixins: [BaseList],
    data() {
      return {
        columns: [
          {
            title: '序号',
            type: 'indexColumn',
            width: 100,
            dataIndex: 'serial',
            scopedSlots: {customRender: 'serial'}
          },
          {title: this.i18n('form.instanceID','流程实例ID'), dataIndex: 'instId', width: 100},
          {title: this.i18n('form.owner','所有人ID'), dataIndex: 'ownerId', width: 100},
          {title: this.i18n('form.title','任务标题'), dataIndex: 'subject', width: 100},
          {title: this.i18n('form.task','任务ID'), dataIndex: 'taskId', width: 100},
          {title: this.i18n('transferPage.transferor','转办人')+"ID", dataIndex: 'toUserId', width: 100},
          {title: this.i18n('form.type','类型(trans,agent)'), dataIndex: 'type', width: 100},
          {title: this.$ti18('rxList.action','操作'), width: 100, dataIndex: 'action', scopedSlots: {customRender: 'action'}}
        ],
        component:BpmTaskTransferEdit,
        comment:this.i18n('list.comment','流程任务转移记录'),
        widthHeight:['800px','600px']
      }
    },
    methods:{
        i18n(name,text,key){
            return this.$ti18(name,text,"bpmTask",key);
        },
      delById(ids){
        return BpmTaskTransferApi.del({ ids: ids.join(',') });
      },
      getListByParams(parameter){
        return BpmTaskTransferApi.query(parameter)
      }
    }
  }
</script>
<style scoped>

</style>

